package com.liwentao.seckill.util;

import org.thymeleaf.util.StringUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValidatorUtil {
    private static final Pattern mobile_pattern=Pattern.compile( "0\\d{2,3}[-]?\\d{7,8}|0\\d{2,3}\\s?\\d{7,8}|13[0-9]\\d{8}|15[1089]\\d{8}");
    private static final Pattern password_pattern=Pattern.compile( "^(?![^a-zA-Z]+$)(?!\\D+$).{8,}$");

    public static boolean isMobile(String mobile){
        if(StringUtils.isEmpty(mobile)){
            return false;
        }
        Matcher matcher=mobile_pattern.matcher(mobile);
        return  matcher.matches();
    }
    public static boolean isPassword(String password){
        if(StringUtils.isEmpty(password)){
            return false;
        }
        Matcher matcher=password_pattern.matcher(password);
        return  matcher.matches();
    }
}
